<?php
/* SVN FILE: $Id: player_types_controller.php 308 2010-07-07 12:26:46Z gregory.rome $ */
/**
 * PlayerTypes Controller.
 *
 * Player types.
 *
 * cBBweb : Digital Blood Bowl league interface (http://code.google.com/p/cbbweb/)
 * Copyright 2009-2010, Grégory Romé.
 *
 * Licensed under The MIT License
 * Redistributions of files must retain the above copyright notice.
 *
 * @filesource
 * @copyright     Copyright 2009-2010, Grégory Romé.
 * @link          http://code.google.com/p/cbbweb/ cBBweb Project
 * @package       cbbweb
 * @subpackage    cbbweb.controllers
 * @version       $Revision: 308 $
 * @modifiedby    $LastChangedBy: gregory.rome $
 * @lastmodified  $Date: 2010-07-07 12:26:46 +0000 (Wed, 07 Jul 2010) $
 * @license       http://www.opensource.org/licenses/mit-license.php The MIT License
 */

/**
 * PlayerTypes Controller.
 *
 * @package       cbbweb
 * @subpackage    cbbweb.controllers
 */
class PlayerTypesController extends AppController {

	var $name = 'PlayerTypes';
    var $paginate = array(
    	'PlayerType' => array(
	    	'contain' => array(
    			'LocalizedString',
    				'Skill' => array(
						'LocalizedString',
						'FormattedString'
					)
			)),
    	'Skill' => array(
				'LocalizedString',
				'FormattedString'
			)
    );

	function index() {
		$this->set('playerTypes', $this->paginate('PlayerType'));
	}

	function view($id = null) {
		if (!$id) {
			$this->Session->setFlash(__('Invalid Player Type.', true));
			$this->redirect(array('action'=>'index'));
		}

		$playerType = $this->PlayerType->find('first', array(
			'contain' => array(
    			'LocalizedString',
					'Race' => array('LocalizedString'),
					'PlayerBasetype' => array('fields' => 'CONSTANT'),
    			'Skill' => array(
						'LocalizedString',
						'FormattedString'
					)),
			'conditions' => array('PlayerType.ID'=> $id)
		));
		$this->set('playerType', $playerType);
	}

}
?>
